package com.whsxt.common.util;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 *    文件上传 下载工具类
 * @author Administrator
 *
 */
public class FileUpdateUtil {
	/**
	 *  图片的路径
	 */
	public static String diskPath =  "F:/imgpath/";
	
	static {
		InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("diskpath.properties");
		if(in == null) {
			throw new RuntimeException("diskpath.properties文件初始化失败");
		}
		Properties prop = new Properties();
		try {
			prop.load(in);
		} catch (IOException e) {
			e.printStackTrace();
		}
		diskPath = prop.getProperty("diskpath");
	}
	
	
	/**
	 *   通过图片的路径删除图片
	 * @param goodsimg
	 */
	public static void deleteFileByimgpath(String goodsimg) {
		if (!goodsimg.equals(ConstantUtil.DEFAULT_IMG)) {
			File file = new File(diskPath, goodsimg);
			if(file.exists()) {
				file.delete();
			}
		}
	}
	
	
	
}
